--require "base_def"
skynet = require "skynet"
cluster = require "skynet.cluster"
log = require "log" 
local socket = require "skynet.socket"

local wg_manager = {}

--init
function wg_manager:Init()
    log.info("-----------------------wg_manager init-----------------------")
    --[[
    --管理节点ID
    self.node = g_manager_node.wg
    skynet.register(".wg")
    --集群模式下开放云节点
    if FRAME_CALL_TYPE==__CALL_TYPE_CLUSTER__ then
        cluster.open "wg"
    end

--]]
    --pb处理模块加载
    --LoadFiles(self)
    
    --web监听服务：首次http的短连接认证版本号等信息
    --local hand_web_connect = skynet.uniqueservice('service_web_connect')
    --local hand_web_connect = skynet.uniqueservice('test')


    --local hand_web_connect = skynet.newservice('wd')
    local wd = skynet.newservice("watchdog")
    ---[[
    skynet.call(wd, "lua", "start", {
		port = 9090,
		maxclient = 64,
		nodelay = true,
	})
    --]]
	skynet.error("Watchdog listen on", 9090)
	--skynet.exit()

    --skynet.newservice("debug_console", 8000)
end

--skynet.start
skynet.start(function()
    skynet.dispatch("lua", function(session, address, cmd, ...)
        log.info("wg_manager dispatch cmd=", cmd)
        local f = wg_manager[cmd]
        if f then
            skynet.ret(skynet.pack(f(wg_manager, ...)))
        else
            log.error(string.format("Unknown command %s", tostring(cmd)))
        end
    end)

    wg_manager:Init()
end)

return wg_manager

